﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Telerik.Web.UI;
using SMA.GENTEv1;

public partial class Protegidos_Administracao_Cadastros__popup_wf_acpwFolhaPagamento : System.Web.UI.Page
{
    int idPatrocinador = 0;
    int idPrestador = 0;
    int idContrato = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["IdPatrocinador"] != null)
            idPatrocinador = Int32.Parse(Request.QueryString["IdPatrocinador"].ToString());

        if (Request.QueryString["IdPrestador"] != null)
            idPrestador = Int32.Parse(Request.QueryString["IdPrestador"].ToString());

        if (Request.QueryString["IdContrato"] != null)
            idContrato = Int32.Parse(Request.QueryString["IdContrato"].ToString());

        if (!IsPostBack)
        {
            OcultaCampos(true);
            DesabilitaCampos(true);
        }

    }

    #region Eventos
    protected void btnSalvar_Click(object sender, EventArgs e)
    {

    }
    protected void btnLimpar_Click(object sender, EventArgs e)
    {

    }
    protected void btnCancelar_Click(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", true);
    }
    
    //Salario Normal
    protected void rcbFormaPagamento_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (int.Parse(rcbFormaPagamento.SelectedValue) == 1)
        {
            dvPagUnico.Visible = true;
            dvPag2.Visible = false;
        }
        else
        {
            dvPagUnico.Visible = false;
            dvPag2.Visible = true;
        }
    }
    protected void rcbTpDia1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (int.Parse(rcbTpDia1.SelectedValue) == 1)
        {
            CarregaDia(rcbDia1);
            rcbDia1.Enabled = true;
        }
        else
        {
            CarregaDiaUtil(rcbDia1);
            rcbDia1.Enabled = true;
        }
    }
    protected void rcbTpDia2_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (int.Parse(rcbTpDia2.SelectedValue) == 1)
        {
            CarregaDia(rcbDia2);
            rcbDia2.Enabled = true;
        }
        else
        {
            CarregaDiaUtil(rcbDia2);
            rcbDia2.Enabled = true;
        }
    }
    protected void rcbTpDia3_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (int.Parse(rcbTpDia3.SelectedValue) == 1)
        {
            CarregaDia(rcbDia3);
            rcbDia3.Enabled = true;
        }
        else
        {
            CarregaDiaUtil(rcbDia3);
            rcbDia3.Enabled = true;
        }
    }

    //13 Salario
    protected void rcb13P1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (int.Parse(rcb13P1.SelectedValue) == 1)
            dv13Parc1.Visible = false;
        else
            dv13Parc1.Visible = true;
    }
    protected void rcb13P2_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (int.Parse(rcb13P2.SelectedValue) == 1)
            dv13Parc2.Visible = false;
        else
            dv13Parc2.Visible = true;
    }
    protected void rcb13P1Forma_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (int.Parse(rcb13P1Forma.SelectedValue) == 1)
        {
            CarregaDia(rcb13P1Dia);
            rcb13P1Dia.Enabled = true;
        }
        else
        {
            CarregaDiaUtil(rcb13P1Dia);
            rcb13P1Dia.Enabled = true;
        }
    }
    protected void rcb13P2Forma_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        if (int.Parse(rcb13P2Forma.SelectedValue) == 1)
        {
            CarregaDia(rcb13P2Dia);
            rcb13P2Dia.Enabled = true;
        }
        else
        {
            CarregaDiaUtil(rcb13P2Dia);
            rcb13P2Dia.Enabled = true;
        }
    }
    #endregion

    #region Metodos
    protected void CarregaDia(RadComboBox combo)
    {
        combo.Items.Clear();
        combo.Text = "";
        for (int i = 31; i >= 1; i--)
        {
            combo.Items.Insert(0, new RadComboBoxItem(i.ToString(), i.ToString()));
        }
    }
    protected void CarregaDiaUtil(RadComboBox combo)
    {
        combo.Items.Clear();
        combo.Text = "";
        for (int i = 27; i >= 1; i--)
        {
            combo.Items.Insert(0, new RadComboBoxItem(i.ToString() + "º", i.ToString()));
        }
    }
    protected void OcultaCampos(bool oculta)
    {
        dvPagUnico.Visible = !oculta;
        dvPag2.Visible = !oculta;
        dv13Parc1.Visible = !oculta;
        dv13Parc2.Visible = !oculta;
    }
    protected void DesabilitaCampos(bool desabilita)
    {
        rcbDia1.Enabled = !desabilita;
        rcbDia2.Enabled = !desabilita;
        rcbDia3.Enabled = !desabilita;
        rcb13P1Dia.Enabled = !desabilita;
        rcb13P2Dia.Enabled = !desabilita;
    }
    #endregion
}
